home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / dragon-runner.swf / scripts / ItemManager.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  3.1 KB  |  110 lines

  1. package
  2. {
  3.    import flash.display.Sprite;
  4.    import flash.events.Event;
  5.    
  6.    public class ItemManager extends Sprite
  7.    {
  8.        
  9.       
  10.       private var ┬º\x01\x01\x02\t┬º:*;
  11.       
  12.       private var ┬º\x01\x01\x02\r┬º:*;
  13.       
  14.       private var ┬º\x01\x01\x07\x06┬º:* = null;
  15.       
  16.       private var ┬º\x01\x01\x07\x07┬º:int;
  17.       
  18.       private var ┬º\x01\x01\x06\r┬º:*;
  19.       
  20.       private var ┬º\x01\x01\x02\x10┬º:*;
  21.       
  22.       private var ┬º\x01\x01\x07\b┬º:String;
  23.       
  24.       private var ┬º\x01\x01\x07\n┬º:int = 0;
  25.       
  26.       public function ItemManager(param1:*, param2:*, param3:*)
  27.       {
  28.          ┬º\x01\x01\x07\x06┬º = null;
  29.          ┬º\x01\x01\x07\n┬º = 0;
  30.          super();
  31.          ┬º\x01\x01\x02\t┬º = param1;
  32.          ┬º\x01\x01\x06\r┬º = param2.GetSceneContainer();
  33.          ┬º\x01\x01\x02\x10┬º = param3;
  34.       }
  35.       
  36.       public function StopGame() : *
  37.       {
  38.          if(┬º\x01\x01\x07\x06┬º != null)
  39.          {
  40.             RemoveItem();
  41.          }
  42.          ┬º\x01\x01\x02\t┬º.removeEventListener(Event.ENTER_FRAME,┬º\x01\x01\x06\x0e┬º);
  43.       }
  44.       
  45.       public function StartGame() : *
  46.       {
  47.          ┬º\x01\x01\x02\t┬º.addEventListener(Event.ENTER_FRAME,┬º\x01\x01\x06\x0e┬º,false,0,true);
  48.       }
  49.       
  50.       private function ┬º\x01\x01\x06\x0e┬º(param1:Event) : *
  51.       {
  52.          if(┬º\x01\x01\x07\t┬º())
  53.          {
  54.             if(┬º\x01\x01\x07\x06┬º != null)
  55.             {
  56.                RemoveItem();
  57.             }
  58.             if(┬º\x01\x01\x02\x10┬º.GetKnightArmor() < 50)
  59.             {
  60.                ┬º\x01\x01\x07\b┬º = "armor";
  61.             }
  62.             else if(┬º\x01\x01\x02\x10┬º.GetKnightHealth() < 50)
  63.             {
  64.                ┬º\x01\x01\x07\b┬º = "health";
  65.             }
  66.             else if(┬º\x01\x01\x02\x10┬º.GetKnightArmor() >= 100 && ┬º\x01\x01\x02\x10┬º.GetKnightHealth() >= 100)
  67.             {
  68.                ┬º\x01\x01\x07\b┬º = "speed";
  69.             }
  70.             else if(Math.random() < 0.2)
  71.             {
  72.                ┬º\x01\x01\x07\b┬º = "speed";
  73.             }
  74.             else if(Math.random() < 0.4)
  75.             {
  76.                ┬º\x01\x01\x07\b┬º = "health";
  77.             }
  78.             else if(Math.random() < 0.6)
  79.             {
  80.                ┬º\x01\x01\x07\b┬º = "armor";
  81.             }
  82.             else
  83.             {
  84.                ┬º\x01\x01\x07\b┬º = "full";
  85.             }
  86.             ┬º\x01\x01\x07\x06┬º = new item();
  87.             ┬º\x01\x01\x07\x06┬º.Init(┬º\x01\x01\x02\t┬º,┬º\x01\x01\x06\r┬º,this,┬º\x01\x01\x07\b┬º);
  88.             ┬º\x01\x01\x06\r┬º.addChild(┬º\x01\x01\x07\x06┬º);
  89.          }
  90.       }
  91.       
  92.       public function RemoveItem() : *
  93.       {
  94.          ┬º\x01\x01\x06\r┬º.removeChild(┬º\x01\x01\x07\x06┬º);
  95.          ┬º\x01\x01\x07\x06┬º = null;
  96.       }
  97.       
  98.       private function ┬º\x01\x01\x07\t┬º() : Boolean
  99.       {
  100.          if(┬º\x01\x01\x07\n┬º <= 0)
  101.          {
  102.             ┬º\x01\x01\x07\n┬º = Math.round(20000 / 42);
  103.             return true;
  104.          }
  105.          --┬º\x01\x01\x07\n┬º;
  106.          return false;
  107.       }
  108.    }
  109. }
  110.